<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>scapi.ApiConnector</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="scapi-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            >SoundCloud API</th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="scapi-module.html">Package&nbsp;scapi</a> ::
        Class&nbsp;ApiConnector
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="scapi.ApiConnector-class.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class ApiConnector</h1><span class="codelink"><a href="scapi-pysrc.html#ApiConnector">source&nbsp;code</a></span><br /><br />
<pre class="base-tree">
object --+
         |
        <strong class="uidshort">ApiConnector</strong>
</pre>

<hr />
The ApiConnector holds all the data necessary to authenticate against 
  the soundcloud-api. You can instantiate several connectors if you like, 
  but usually one should be sufficient.<br /><br />

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="scapi.ApiConnector-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">host</span>,
        <span class="summary-sig-arg">user</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">password</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">authenticator</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">base</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string"></code><code class="variable-quote">'</code></span>,
        <span class="summary-sig-arg">collapse_scope</span>=<span class="summary-sig-default">True</span>)</span><br />
      Constructor for the API-Singleton.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="scapi-pysrc.html#ApiConnector.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="scapi.ApiConnector-class.html#normalize_method" class="summary-sig-name">normalize_method</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">method</span>)</span><br />
      This method will take a method that has been part of a redirect of
      some sort and see if it's valid, which means that it's located 
      beneath our base.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="scapi-pysrc.html#ApiConnector.normalize_method">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="scapi.ApiConnector-class.html#fetch_request_token" class="summary-sig-name">fetch_request_token</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">url</span>=<span class="summary-sig-default">None</span>)</span><br />
      Helper-function for a registered consumer to obtain a request 
      token, as used by oauth.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="scapi-pysrc.html#ApiConnector.fetch_request_token">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="scapi.ApiConnector-class.html#fetch_access_token" class="summary-sig-name">fetch_access_token</a>(<span class="summary-sig-arg">self</span>)</span><br />
      Helper-function for a registered consumer to exchange an access 
      token for a request token.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="scapi-pysrc.html#ApiConnector.fetch_access_token">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="scapi.ApiConnector-class.html#get_request_token_authorization_url" class="summary-sig-name">get_request_token_authorization_url</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">token</span>)</span><br />
      Simple helper function to generate the url needed to ask a user 
      for request token authorization.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="scapi-pysrc.html#ApiConnector.get_request_token_authorization_url">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__delattr__</code>,
      <code>__getattribute__</code>,
      <code>__hash__</code>,
      <code>__new__</code>,
      <code>__reduce__</code>,
      <code>__reduce_ex__</code>,
      <code>__repr__</code>,
      <code>__setattr__</code>,
      <code>__str__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== CLASS VARIABLES ==================== -->
<a name="section-ClassVariables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Class Variables</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-ClassVariables"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="LIST_LIMIT"></a><span class="summary-name">LIST_LIMIT</span> = <code title="50">50</code><br />
      The query-parameter that is used to request results beginning from
      a certain offset.
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="scapi.ApiConnector-class.html#LIST_OFFSET_PARAMETER" class="summary-name">LIST_OFFSET_PARAMETER</a> = <code title="'offset'"><code class="variable-quote">'</code><code class="variable-string">offset</code><code class="variable-quote">'</code></code><br />
      The query-parameter that is used to request results being limited 
      to a certain amount.
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="LIST_LIMIT_PARAMETER"></a><span class="summary-name">LIST_LIMIT_PARAMETER</span> = <code title="'limit'"><code class="variable-quote">'</code><code class="variable-string">limit</code><code class="variable-quote">'</code></code>
    </td>
  </tr>
</table>
<!-- ==================== PROPERTIES ==================== -->
<a name="section-Properties"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Properties</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Properties"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__class__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Method Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-MethodDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="__init__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">host</span>,
        <span class="sig-arg">user</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">password</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">authenticator</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">base</span>=<span class="sig-default"><code class="variable-quote">'</code><code class="variable-string"></code><code class="variable-quote">'</code></span>,
        <span class="sig-arg">collapse_scope</span>=<span class="sig-default">True</span>)</span>
    <br /><em class="fname">(Constructor)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="scapi-pysrc.html#ApiConnector.__init__">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  Constructor for the API-Singleton. Use it once with parameters, and 
  then the subsequent calls internal to the API will work.
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>host</code></strong> (str) - the host to connect to, e.g. &quot;api.soundcloud.com&quot;. 
          If a port is needed, use &quot;api.soundcloud.com:1234&quot;</li>
        <li><strong class="pname"><code>user</code></strong> (str) - if given, the username for basic HTTP authentication</li>
        <li><strong class="pname"><code>password</code></strong> (str) - if the user is given, you have to give a password as well</li>
        <li><strong class="pname"><code>authenticator</code></strong> (OAuthAuthenticator | BasicAuthenticator) - the authenticator to use, see <a 
          href="scapi.authentication-module.html" 
          class="link">scapi.authentication</a></li>
    </ul></dd>
    <dt>Overrides:
      object.__init__
    </dt>
  </dl>
</td></tr></table>
</div>
<a name="normalize_method"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">normalize_method</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">method</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="scapi-pysrc.html#ApiConnector.normalize_method">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  This method will take a method that has been part of a redirect of 
  some sort and see if it's valid, which means that it's located beneath 
  our base. If yes, we return it normalized without that very base.
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="fetch_request_token"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">fetch_request_token</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">url</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="scapi-pysrc.html#ApiConnector.fetch_request_token">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  <p>Helper-function for a registered consumer to obtain a request token, 
  as used by oauth.</p>
  Use it like this:
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>oauth_authenticator = scapi.authentication.OAuthAuthenticator(CONSUMER, 
<span class="py-output">                                                          CONSUMER_SECRET,</span>
<span class="py-output">                                                          None, </span>
<span class="py-output">                                                          None)</span></pre>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>sca = scapi.ApiConnector(host=API_HOST, authenticator=oauth_authenticator)
<span class="py-prompt">&gt;&gt;&gt; </span>token, secret = sca.fetch_request_token()
<span class="py-prompt">&gt;&gt;&gt; </span>authorization_url = sca.get_request_token_authorization_url(token)</pre>
  Please note the None passed as  token &amp; secret to the 
  authenticator.
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="fetch_access_token"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">fetch_access_token</span>(<span class="sig-arg">self</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="scapi-pysrc.html#ApiConnector.fetch_access_token">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  <p>Helper-function for a registered consumer to exchange an access token 
  for a request token.</p>
  Use it like this:
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>oauth_authenticator = scapi.authentication.OAuthAuthenticator(CONSUMER, 
<span class="py-output">                                                          CONSUMER_SECRET,</span>
<span class="py-output">                                                          request_token, </span>
<span class="py-output">                                                          request_token_secret)</span></pre>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>sca = scapi.ApiConnector(host=API_HOST, authenticator=oauth_authenticator)
<span class="py-prompt">&gt;&gt;&gt; </span>token, secret = sca.fetch_access_token()</pre>
  Please note the values passed as token &amp; secret to the 
  authenticator.
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="get_request_token_authorization_url"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">get_request_token_authorization_url</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">token</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="scapi-pysrc.html#ApiConnector.get_request_token_authorization_url">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  <p>Simple helper function to generate the url needed to ask a user for 
  request token authorization.</p>
  <p>See also <a href="scapi.ApiConnector-class.html#fetch_request_token" 
  class="link">fetch_request_token</a>.</p>
  Possible usage:
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">import</span> webbrowser
<span class="py-prompt">&gt;&gt;&gt; </span>sca = scapi.ApiConnector()
<span class="py-prompt">&gt;&gt;&gt; </span>authorization_url = sca.get_request_token_authorization_url(token)
<span class="py-prompt">&gt;&gt;&gt; </span>webbrowser.open(authorization_url)</pre>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== CLASS VARIABLE DETAILS ==================== -->
<a name="section-ClassVariableDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Class Variable Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-ClassVariableDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="LIST_OFFSET_PARAMETER"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">LIST_OFFSET_PARAMETER</h3>
  <p>The query-parameter that is used to request results being limited to a
  certain amount.</p>
  Currently this is of no use and just for completeness sake.
  <dl class="fields">
  </dl>
  <dl class="fields">
    <dt>Value:</dt>
      <dd><table><tr><td><pre class="variable">
<code class="variable-quote">'</code><code class="variable-string">offset</code><code class="variable-quote">'</code>
</pre></td></tr></table>
</dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="scapi-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            >SoundCloud API</th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0beta1 on Fri Apr 18 16:28:18 2008
    </td>
    <td align="right" class="footer">
      <a href="http://epydoc.sourceforge.net">http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie()
  // -->
</script>
  
</body>
</html>
